<template>
  <div>
    <FilterTable
      ref="table"
      :columns="columns"
      height="auto"
      :dataSource="changeList"
      :isPagination='false'
      :isToperInfo='false'
      :isColumnFilter='false'
      :isSelectColumn='false'
      selectionType="single"
      :onColumnsChange="columns => this.columns = columns"
    ></FilterTable>
  </div>
</template>

<script>
import { queryChangeList } from '@/api/potenCus/customer/potenCusManage';
import { dictionary } from '@/utils/dictMixin';
import { formatDates } from '@/utils/validate';

export default {
  name: 'changeHistory',
  mixins: [dictionary],
  props: {
    type: {
      type: String,
      default: 'show'
    },
    rowData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.saveData = null;
    return {
      changeList: [],
      columns: this.createTableColumns(),
      handleType: '',
      formData: {},
    };
  },
  created() {
    this.init();
    this.getAboutCluesList()
  },
  methods: {
    init() {
      if (this.type === 'edit' || this.type === 'show') {
        // 更新接口需要的记录 ID
        console.log('变更', this.rowData)
        this.recordId = this.rowData.potentialCustomersId;
      }
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '变更字段',
          dataIndex: 'changeDate',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props =>{
            return <span>{ formatDates(props.row.changeDate) } </span>
          }
        },
        {
          title: '变更前',
          dataIndex: 'personnelName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '变更后',
          dataIndex: 'changeMatter',
          sorter: true,
          filter: true,
          filterType: 'input',
          // filterType: 'checkbox',
          // filterItems: this.createDictList('7045'),
          // render: props => {
          //   return <span>{this.createDictText(props.row.changeMatter, '7045')}</span>;
          // }
        },
        {
          title: '变更人',
          dataIndex: 'remark',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '变更时间',
          dataIndex: 'date',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    async getAboutCluesList() {
      const res = await queryChangeList(this.recordId)
      // const res = await queryChangeList(632)
      console.log('变更', res)
      if (res.resultCode === 200) {
        this.changeList = res.data;
      }
    },

  }
};
</script>

<style lang="less" scoped>
</style>

